package day5;

import java.util.Scanner;

public class demo1 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        for (int i = 0; i <n ; i++) {
         int y=scanner.nextInt();
         int o=scanner.nextInt();
         int u=scanner.nextInt();
         int ret=0;
         int k=Math.min(y,u);
            if(o>=k){
                ret+=k*2;
                o-=k;
            }else {
                ret+=o*2;
                o=0;
            }
            if (o>=2){
                ret+=o-1;
            }
            System.out.println(ret);
        }
    }




}
